#include "objectmanager.h"

ObjectManager::ObjectManager(QObject *parent) : QObject(parent)
{
    mIcon = new QSystemTrayIcon(this);
    mIcon->setIcon(QIcon::fromTheme("firefox"));
    mIcon->setVisible(true);

    connect(mIcon , SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(showmWidget(QSystemTrayIcon::ActivationReason)));

}

void ObjectManager::showmWidget(QSystemTrayIcon::ActivationReason reason){
    switch(reason)
    {
    // 单击托盘显示窗口
    case QSystemTrayIcon::Trigger:
    {
        if(mWidget==nullptr){
            mWidget = new Widget();
            qDebug()<<"******** new";
            connect(mIcon , SIGNAL(activated(QSystemTrayIcon::ActivationReason)), mWidget, SLOT(onActivated(QSystemTrayIcon::ActivationReason)));
        }
        mWidget->show();
    }
    // 双击
    case QSystemTrayIcon::DoubleClick:
    {
        // ...
        break;
    }
    default:
        break;
    }

}
